package front

import (
	"hft/Http/Models/request/front"
	utils "hft/Http/Utils"

	"gorm.io/gorm"
)

type Arc struct{}

func (a *Arc) List(paginate *front.ArcPage, region_link string, types []int, db *gorm.DB) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		return db.Where("region_link LIKE ?", region_link).Scopes(a.Type(types, db)).Order("create_time desc").Scopes(utils.Paginate(paginate.Page, db))
	}
}

func (a *Arc) Type(types []int, db *gorm.DB) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		if len(types) == 0 {
			return db
		} else {
			return db.Where("art_type IN ?", types)
		}
	}
}

var ArcDao = new(Arc)
